﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Diagnostics;

namespace Auction_Boxing_2
{
    public class StateDashing : State
    {
        const float SpeedFactor = 3f;

        const int DashTime = 100;

        const int Wait = 1;

        GameTimer DashTimer;

        DirectionType Direction;

        public StateDashing(DirectionType Direction, State state)
        {
            StateName = "moving";
            this.ATextures = state.StatePlayer.ATextures;
            this.Direction = Direction;

            LoadState(state.StatePlayer, ATextures);

        }

        public override void LoadState(BoxingPlayer player, Dictionary<string, Animation> ATextures)
        {
            this.StatePlayer = player;
            this.ATextures = ATextures;
            this.PlayerAnimation = ATextures[StateName];

            this.speed = new Vector2(Tools.speedCalc(StatePlayer.MaxMovement), Tools.Y_SCALE * Tools.speedCalc(StatePlayer.MaxMovement));

            DashTimer = new GameTimer(Wait, DashTime);

            DashTimer.Start();

            StatePlayer.isAttacking = false;
            StatePlayer.isHit = false;


        }

        public override void Initialize()
        {



        }



        public override void Update(GameTime gameTime)
        {

        }

        public override void HandleMovement()
        {

            switch (Direction)
            {
                case DirectionType.Up:
                    Translate(0, SpeedFactor * speed.Y);
                    break;

                case DirectionType.Down:
                    Translate(0, SpeedFactor * -speed.Y);
                    break;

                case DirectionType.Right:
                    Translate(SpeedFactor * speed.X, 0);
                    break;

                case DirectionType.Left:
                    Translate(SpeedFactor * -speed.X, 0);
                    break;

                case DirectionType.None:

                    break;

                default:

                    break;
            }

        }

        public override void HandleDirection()
        {



        }

        public override void HandleState()
        {
            if (!DashTimer.Enabled)
                StatePlayer.InternalState = new StateMoving(this);
        }

        public override void Translate(float x, float y)
        {
            Vector3 Temp = StatePlayer.Position;
            Temp.X += x;
            Temp.Y += y;
            StatePlayer.Position = Temp;

        }

        public override void HandleCollision(List<BoxingPlayer> Players)
        {

        }
    }
}
